package Thread;

public class ThreadDemo3 {
    public static void main(String[] args) {
        Thread t1 = new Thread() {
            @Override
            public void run() {
                for (int i = 0; i <= 1000; i++) {
                    System.out.println("查水表的！");
                }
            }
        };

//        Runnable r1 =  () -> {
//                for (int i=0;i<=1000;i++){
//                    System.out.println("你开门！");
//                }
//        };
        //因为Runnable接口中只有一个需要实现的run方法所以 此处可以直接使用lambda写法
        Thread t2 = new Thread(() -> {
            for (int i = 0; i <= 1000; i++) {
                System.out.println("你开门！");
            }
        });

        t1.start();
        t2.start();
    }
}
